<?php
if (!defined('S')) die("Access Denied");

include_once 'model/post.php';
$obj = new post();
$id = uri(2);

if (!empty($id)) {
    $list = array($obj->getOne($id));
} else {
    $list = $obj->getAll();
}
?>
<div id="posts">
    <?php foreach ($list as $p) { ?>
    <div id="post<?php echo $p['id']; ?>" class="bgwhite">
        <div class="post">
            <div class="info">
                <h2><a href="/blog/id/<?php echo $p['id']; ?>"><?php echo $p['title']; ?></a></h2>
                <?php echo $p['created_at']; ?>
            </div>
            <!--<div class="info">
                <a href="/blog/pdf/post/<?php echo $p['id']; ?>"  onfocus="this.blur();" >
                    <img src="<?php echo IMG_HOST; ?>acrobat.png" width="64" height="64" alt="PDF版本" />
                </a>
            </div>-->
            <div class="cl"></div>
            <div class="content">
                <?php echo empty($id) ? (mb_substr($p['content'], 0, 350, 'UTF-8') . '...') : $p['content']; ?>
            </div>
            <div class="backToTop" onclick="javascript:scroll(0,0);">
                <div class="backToTopText">
                    <?php __('backtotop'); ?>
                </div>
            </div>
        </div>
    </div>
    <?php } ?>
</div>